﻿%YAML 1.2
---
# IL.sublime-syntax
# 
#  Author:
#    Mike Krüger <mikkrg@microsoft.com>
# 
#  Copyright (c) 2016 Microsoft Corporation
# 
#  Permission is hereby granted, free of charge, to any person obtaining a copy
#  of this software and associated documentation files (the "Software"), to deal
#  in the Software without restriction, including without limitation the rights
#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#  copies of the Software, and to permit persons to whom the Software is
#  furnished to do so, subject to the following conditions:
# 
#  The above copyright notice and this permission notice shall be included in
#  all copies or substantial portions of the Software.
# 
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#  THE SOFTWARE.

name: "IL"
file_extensions:
  - il
scope: source.il
contexts:
  main:
    - include: comments
    - include: keywords
    - include: numbers
    - include: strings
    - include: preprocessor
  comments:
    - match: '//'
      scope: comment.line.source.il
      push:
        - include: commenttags
        - match: $\n?
          pop: true
    - match: '/\*'
      scope: comment.block.source.il
      push:
        - include: commenttags
        - match: '\*/\n?'
          pop: true
  commenttags:
    - match: '\b((?i:todo)|(?i:fixme)|(?i:hack)|(?i:undone))\b'
      scope: markup.other.source.il
  keywords:
    - match: '\b(nop|break|ldarg.0|ldarg.1|ldarg.2|ldarg.3|ldloc.0|ldloc.1|ldloc.2|ldloc.3|stloc.0|stloc.1|stloc.2|stloc.3|ldnull|ldc.i4.m1|ldc.i4.M1|ldc.i4.0|ldc.i4.1|ldc.i4.2|ldc.i4.3|ldc.i4.4|ldc.i4.5|ldc.i4.6|ldc.i4.7|ldc.i4.8|dup|pop|ret|ldind.i1|ldind.u1|ldind.i2|ldind.u2|ldind.i4|ldind.u4|ldind.i|ldind.r4|ldind.r8|ldind.ref|stind.ref|stind.i1|stind.i2|stind.i4|stind.i8|stind.r4|stind.r8|add|sub|mul|div|div.un|rem|rem.un|and|or|xor|shl|shr|shr.un|neg|not|conv.i1|conv.i2|conv.i4|conv.i8|conv.r4|conv.r8|conv.u4|conv.u8|conv.r.un|throw|conv.ovf.i1.un|conv.ovf.i2.un|conv.ovf.i4.un|conv.ovf.i8.un|conv.ovf.u1.un|conv.ovf.u2.un|conv.ovf.u4.un|conv.ovf.u8.un|conv.ovf.i.un|conf.ovf.u.un|ldlen|ldelem.i1|ldelem.u1|ldelem.i2|ldelem.u2|ldelem.i4|ldelem.u4|ldelem.i8|ldelem.u8|ldelem.i|ldelem.r4|ldelem.r8|ldelem.ref|stelem.i|stelem.i1|stelem.i2|stelem.i4|stelem.i8|stelem.r4|stelem.r8|stelem.ref|conv.ovf.i1|conv.ovf.u1|conv.ovf.i2|conv.ovf.u2|conv.ovf.i4|conv.ovf.u4|conv.ovf.i8|conv.ovf.u8|ckfinite|conv.u2|conv.u1|conv.i|conv.ovf.i|conv.ovf.u|add.ovf|add.ovf.un|mul.ovf|mul.ovf.un|sub.ovf|sub.ovf.un|endfinally|endfault|stind.i|conv.u|arglist|ceq|cgt|cgt.un|clt|clt.un|localloc|endfilter|volatile.|tail.|cpblk|initblk|rethrow|refanytype|readonly.|ldarg|ldarga|starg|ldarg.s|ldarga.s|starg.s|ldloc|ldloca|stloc|ldloc.s|ldloca.s|stloc.s|ldc.i4.s|ldc.i4|unaligned.|cpobj|ldobj|castclass|isinst|unbox|unbox.any|stobj|box|newarr|ldelema|refanyval|mkrefany|initobj|sizeof|stelem|ldelem|stelem.any|ldelem.any|constrained.|jmp|call|callvirt|newobj|ldftn|ldvirtftn|ldfld|ldflda|stfld|ldsfld|ldsflda|stsfld|br|brfalse|brzero|brnull|brtrue|beq|bge|bgt|ble|blt|bne.un|bge.un|bgt.un|ble.un|blt.un|leave|br.s|brfalse.s|brtrue.s|beq.s|bge.s|bgt.s|ble.s|blt.s|bne.un.s|bge.un.s|bgt.un.s|ble.un.s|blt.un.s|leave.s|ldstr|ldc.r4|ldc.r8|ldc.i8|switch|calli|ldtoken|no.|prefix1|prefix2|prefix3|prefix4|prefix5|prefix6|prefix7|prefixref)\b'
      scope: keyword.source.il
    - match: '\b(void|object|bool|char|string|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float|float32|float64|typedref)\b'
      scope: keyword.type.source.il
    - match: '\b(at|as|implicitcom|implicitres|extern|instance|explicit|default|vararg|unmanaged|cdecl|stdcall|thiscall|fastcall|marshal|in|out|opt|static|public|private|family|initonly|rtspecialname|specialname|assembly|famandassem|famorassem|privatescope|literal|notserialized|value|not_in_gc_heap|interface|sealed|abstract|auto|sequential|ansi|unicode|autochar|bestfit|charmaperror|import|serializable|nested|extends|implements|final|virtual|hidebysig|newslot|unmanagedexp|pinvokeimpl|nomangle|lasterr|winapi|platformapi|native|il|cil|optil|managed|forwardref|runtime|internalcall|synchronized|noinlining|nooptimization|custom|fixed|sysstring|array|variant|currency|syschar|error|unsigned|decimal|date|bstr|lpstr|lpwstr|lptstr|objectref|iunknown|idispatch|struct|safearray|byvalstr|tbstr|lpvoid|any|lpstruct|null|vector|hresult|carray|userdefined|record|filetime|blob|stream|storage|streamed_object|stored_object|blob_object|cf|clsid|method|class|pinned|modreq|modopt|property|type|refany|wchar|fromunmanaged|callmostderived|retainappdomain|bytearray|with|init|to|catch|filter|finally|fault|handler|tls|field|nometadata|algorithm|retargetable|legacy|library|x86|amd64|ia64|preservesig|beforefieldinit|alignment|nullref|valuetype|compilercontrolled|reqsecobj|enum|on|off|strict|mdtoken|noappdomain|noprocess|nomachine|illegal|unused|wrapper|forwarder|callconv|flags)\b'
      scope: keyword.modifier.source.il
    - match: '\b(.assembly|.cctor|.class|.imagebase|.corflags|.ctor|.custom|.data|.emitbyte|.entrypoint|.event|.export|.field|.file|.fire|.get|.hash|.language|.line|.locale|.locals|.maxstack|.method|.module|.mresource|.manifestres|.namespace|.other|.override|.pack|.param|.permission|.permissionset|.property|.publickey|.publickeytoken|.addon|.removeon|.set|.size|.stackreserve|.subsystem|.try|.ver|.vtable|.vtentry|.vtfixup|.zeroinit|.this|.base|.nester|.typelist|.mscorlib|.localized|.pdirect|.typedef)\b'
      scope: keyword.access.source.il
    - match: '\b(request|demand|assert|deny|permitonly|linkcheck|inheritcheck|reqmin|reqopt|reqrefuse|prejitgrant|prejitdeny|noncasdemand|noncaslinkdemand|noncasinheritance)\b'
      scope: keyword.source.il
    - match: '\b(true|false)\b'
      scope: constant.language.source.cs
  numbers:
    - match: '((\b\d+\.?\d+)|(\.\d+))([eE][+-]?\d*)?(F|f|D|d|M|m)?\b'
      scope: constant.numeric.float.source.cs
    - match: '\b(0[xX][0-9a-fA-F]+?|\d+)(U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?\b'
      scope: constant.numeric.source.cs
  strings:
    - match: "'"
      scope: string.quoted.single.source.cs
      push:
        - match: '\\.'
          scope: constant.character.escape.source.cs
        - match: "('|$\n?)"
          pop: true
    - match: '"'
      scope: string.quoted.double.source.cs
      push:
        - match: '\\.'
          scope: constant.character.escape.source.cs
        - match: '("|$\n?)'
          pop: true
  preprocessor:
    - match: '^\s*#(define|else|endif|ifdef|ifndef|include|line|undef)\b'
      scope: meta.preprocessor.source.il
      push:
        - match: '\n?'
          pop: true
